package contegor.scire.persistence.prevayler;

import java.util.Date;

import org.prevayler.Transaction;

import contegor.scire.core.Version;
import contegor.scire.core.modifications.Modification;

/**
 * Prevayler {@link Transaction} that encapsulates a Scire {@link Modification}.
 * 
 * @version $Revision$
 * @author  Héctor Cirbián Pousa ($Author$)
 */
@Version("@(#) $Id$")
public class PrevalentTransaction implements Transaction {
  private static final long serialVersionUID = 7397807696769773332L;

  private Modification modification;

  public PrevalentTransaction(Modification modification) {
    this.modification = modification;
  }

  public void executeOn(Object prevalentSystem, Date executionTime) {
    this.modification.setRelatedTime(executionTime.getTime());
    PrevalentRootContainer rootContainer = ((PrevalentRootContainer)prevalentSystem);
    rootContainer.process(modification, rootContainer.getModificationsReturnPoint());
  }

}
